home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.92 / crossfir / crossfire-0.92.5 / utils / mapconv.script < prev    next >
Text File  |  1996-07-24  |  2KB  |  89 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # mapconv by Jarkko.Sonninen@lut.fi
  4. # converts .om & .oo style maps into another format
  5. #
  6. # to use it, go to map directory and give mapnames as parameters
  7. # .oo and .oo extensions are stripped off the filenames
  8. # for example   
  9. #    mapconv map.01
  10. #    mapconv *.oo
  11. #
  12.  
  13.  
  14. $BMAPS = "../bmaps";
  15.  
  16. open (BM, $BMAPS) || die "aargh";
  17.                 # 
  18. while ($_=<BM>) {
  19.     if (/\\(\d+)\s+(\S*)/) {
  20.     if ($2 eq "dwall_3_3") {
  21.         # kludge alert!
  22.         # try to make an archetype with name "dwall_3_3" and enjoy!
  23.         $face[$1] = "dwall3_3";
  24.     } else {
  25.         $face[$1] = $2;
  26.     }
  27.     }
  28. close (BM);
  29.     
  30. while ($map = shift @ARGV) {
  31.     if ($map =~ /(.*)\.oo$|(.*)\.om$/) {
  32.     $map = $1;
  33.     }
  34.     open (OMAP, "<$map.oo") || die "cannot open $map.oo";
  35.     open (MAP, "<$map.om") || die "cannot open $map.om";
  36.  
  37.     open (OO, ">$map") || die "aargh";
  38.  
  39.     print "converting $map\n";
  40.     
  41.     $_=<MAP>; ($mapx) = /\w+\s+(\d+)/;
  42.     $_=<MAP>; ($mapy) = /\w+\s+(\d+)/;
  43.     $_=<MAP>; ($startx) = /\w+\s+(\d+)/;
  44.     $_=<MAP>; ($starty) = /\w+\s+(\d+)/;
  45.     $_=<MAP>; ($msgsize) = /\w+\s+(\d+)/;
  46.     $_=<MAP>; ($msglines) = /\w+\s+(\d+)/;
  47.  
  48.     print OO "arch map\n";
  49.     print OO "x $mapx\n";
  50.     print OO "y $mapy\n";
  51.     print OO "hp $startx\n";
  52.     print OO "sp $starty\n";
  53.  
  54.     if ($msglines) {
  55.     print OO "msg\n";
  56.     while ($msglines-- > 0) {
  57.         $_=<MAP>;
  58.         print "msg:$_";
  59.         print OO $_;
  60.     }
  61.     print OO "endmsg\n";
  62.     }
  63.     print OO "end\n";
  64.  
  65.     while ($_ = <OMAP>) {
  66.     print OO $_;
  67.     }
  68.     
  69.     print "$mapx x $mapy\n"; 
  70.     for ($i = 0; $i < $mapx; $i++) { 
  71.     for ($j = 0; $j < $mapy; $j++) {
  72.         $_=<MAP>;
  73.         if ($_ != 35) {
  74.         if ($face[$_]) { 
  75.             print OO "arch $face[$_]\n";
  76.             if ($i) {
  77.             print OO "x $i\n";
  78.             }
  79.             if ($j) {
  80.             print OO "y $j\n";
  81.             }
  82.         print OO "end\n";
  83.         }
  84.         }
  85.     }
  86.     }
  87. }
  88.